package com.lkpstudy.rbac.exception;

import com.lkpstudy.rbac.vo.Result;
import com.lkpstudy.rbac.vo.ResultCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author likaiping
 * @editTime 2024/4/19 13:24
 * 该类是统一异常处理
 */
@Slf4j
@ResponseBody
@ControllerAdvice
public class ControllerExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result<Object> exceptionHandler(Exception e) {
        log.error(e.getMessage());
        return Result.error(e.getMessage());
    }
}
